/**
 *
 */
package com.yangtao.framework.hibernate;

import java.util.HashSet;

/**
 * 属性选择器
 *
 * @author 杨涛
 * @version 1.0
 */
public class Selector extends HashSet<String> {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	public Selector() {
		super();
	}

	public Selector(int initialCapacity) {
		super(initialCapacity);
	}

	/**
	 * 根据属性，生成子选择器
	 *
	 * @param property
	 * @return
	 */
	public Selector generateSubSelector(String property) {
		Selector subSelector = new Selector();
		for (String s : this) {
			if (s.contains(property)) {
				subSelector.add(s.substring(property.length() + 1, s.length()));
			}
		}
		return subSelector;
	}

	/**
	 * 判断选择器中是否包含属性
	 *
	 * @param property
	 * @return
	 */
	public boolean containsProperty(String property) {
		for (String s : this) {
			if (s.contains("." + property))
				return true;
		}
		return false;
	}

}
